package com.yhb.channel.utils;

import com.yhb.channel.provider.IUtilProvider;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;

@Data
public class ConfigGetter {

    private IUtilProvider iUtilProvider;
    private String prefix = "";
    private String env = "";

    public ConfigGetter(String prefix, IUtilProvider iUtilProvider) {
        this.setPrefix(prefix);
        this.iUtilProvider = iUtilProvider;
        this.env = iUtilProvider.getProperty("config.payEnv");
    }

    public String get(String key) {
        return iUtilProvider.getProperty(env + "." + prefix + "." + key);
    }

    /**
     * 获取配置  不区分环境
     */
    public String getProperty(String key) {
        return  iUtilProvider.getProperty(prefix + "." + key);
    }
}
